<template>
    <el-card>
        <div slot="header" class="clearfix">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
                <el-breadcrumb-item :to="{ path: '/task/scheduler' }">任务中心</el-breadcrumb-item>
                <el-breadcrumb-item>运行历史</el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <el-table v-loading="loading" :data="datas" height="500" border>
            <el-table-column
                    prop="id"
                    label="ID"
                    width="250">
            </el-table-column>
            <el-table-column
                    prop="task_id"
                    label="任务ID"
                    width="250">
            </el-table-column>
            <el-table-column
                    prop="task_name"
                    label="任务名">
            </el-table-column>
            <el-table-column
                    prop="func_name"
                    label="方法名">
            </el-table-column>
            <el-table-column
                    prop="time"
                    label="运行时间">
                <template slot-scope="scope">
                    {{formatFS(scope.row.time)}}
                </template>
            </el-table-column>
            <el-table-column prop="span_time" label="运行时间(S)">
            </el-table-column>
            <el-table-column
                    prop="user"
                    label="创建用户">
            </el-table-column>
            <el-table-column prop="status" label="状态">
                <template slot-scope="scope">
                    <el-tag v-if="scope.row.status=='1'" type="success">成功</el-tag>
                    <el-tag v-else type="danger">失败</el-tag>
                </template>
            </el-table-column>
            <el-table-column prop="log" label="运行日志">
            </el-table-column>
        </el-table>
    </el-card>
</template>

<script>

    import {obj2datetime, formatTimestamp} from "@/components/common/time";

    export default {
        name: "run_history",
        data() {
            return {
                datas: [],
                loading: false
            }
        }, methods: {
            formatFS(ts) {
                return formatTimestamp(ts)
            },
            init() {
                const _this = this
                this.loading = true
                this.$request({
                    url: '/api/task/run_history.do', method: 'post',
                }).then(res => {
                    _this.loading = false
                    _this.datas = res
                }).finally(() => {
                    this.loading = false
                })
            }
        },
        created() {
            this.init()
        }
    }
</script>

<style scoped>

</style>
